Optimize gtk_widget_path_copy() by preallocating "elems" array
authorMatthias Clasen <mclasen@redhat.com>
Tue, 7 Aug 2012 04:38:48 +0000 (00:38 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 7 Aug 2012 04:38:48 +0000 (00:38 -0400)
commitf89d5c828038654802526c9ea68e6fb52fa461d3
tree7dc99bf24c219756bfe3c9eb10e13ae4c584b2f5
parente2c15e2791870c297bbc8e055dae359f9bc76a0c
Optimize gtk_widget_path_copy() by preallocating "elems" array

gtk_widget_path_copy() currently calls g_array_append_val() in a loop,
which is inefficient due to reallocating the array's memory. Calling
g_array_set_size() before entering the loop reduces the number of CPU
cycles used by roughly 30%.

Patch by John Lindgren,
https://bugzilla.gnome.org/show_bug.cgi?id=679978
gtk/gtkwidgetpath.c